package com.tiankun.eurekasellinfo.controller;

import com.tiankun.eurekasellinfo.pojo.Merchant;
import com.tiankun.eurekasellinfo.service.MerchantService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Map;

/**
 * @Author 杨天可
 * @Date 2020/11/13 10:44
 * @Version 1.0
 */
@Controller
@RequestMapping("/merchant")
public class MerchantController {

    @Resource
    MerchantService merchantService;

    //项目测试
    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        return "success";
    }

    //商家注册
    @RequestMapping("/regist")
    @ResponseBody
    public Map regist(@RequestBody Merchant merchant) throws ParseException {
       return merchantService.regist(merchant);
    }

    //商家登录
    @RequestMapping("/login")
    @ResponseBody
    public Map login(@RequestParam("phone")String phone,@RequestParam("password")String password){
        return merchantService.login(phone,password);
    }

    //忘记密码——>修改密码
    @RequestMapping("/changepwd")
    @ResponseBody
    public  Map changepwd(@RequestParam("phone")String phone,@RequestParam("password")String password,@RequestParam("yzm")String yzm){
        return  merchantService.changepwd(password,phone,yzm);
    }
}
